package com.elink.enginerring.company.service;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.elink.enginerring.blog.dao.BlogMapper;
import com.elink.enginerring.common.ErrorType;
import com.elink.enginerring.common.Pagination;
import com.elink.enginerring.company.co.CompanyCo;
import com.elink.enginerring.company.dao.CompanyMapper;
import com.elink.enginerring.util.JSONUtil;
import com.elink.enginerring.video.dao.CourseMapper;

@Service
public class CompanyService  implements ICompanyService{
	@Autowired
	private CompanyMapper companyMapper;
	@Autowired
	private BlogMapper blogMapper;
	@Autowired
	private CourseMapper courseMapper;

	@Override
	public Map<String, Object> getList(CompanyCo co) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("list",companyMapper.selectList(co));
		map.put("pagination", new Pagination(co, companyMapper.selectCount(co)));
		return JSONUtil.getJSON(ErrorType.SUCCESS,map);
	}

	@Override
	public Map<String, Object> getInfo(String companyId) {
		return JSONUtil.getJSON(ErrorType.SUCCESS,companyMapper.selectInfo(companyId));
	}

	@Override
	public Map<String, Object> addAuth(String ids, int authStatus) {
//		if(authStatus == 2){//不通过审核
//			blogMapper.addAuth(ids, authStatus);
//			courseMapper.addAuth(ids, authStatus);
//		}
		companyMapper.addAuth(ids,authStatus);
		return JSONUtil.getJSON(ErrorType.SUCCESS);
	}
}
